﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ApiBetaSeries.Version
{
    internal static class MethodInfoExtension
    {
        public static string ToGoodString(this MethodInfo method)
        {
            StringBuilder name = new StringBuilder();
            name.Append(method.ReturnType.Name);
            name.Append(" ");
            name.Append(method.DeclaringType.Name);
            name.Append(".");
            name.Append(method.Name);
            name.Append("(");
            if (method.GetParameters().Length > 0)
            {
                foreach (ParameterInfo param in method.GetParameters())
                {
                    name.Append(param.ParameterType.Name);
                    name.Append(" ");
                    name.Append(param.Name);
                    name.Append(", ");
                }
                name.Remove(name.Length - 2, 2);
            }
            name.Append(");");
            return name.ToString();
        }
    }
}
